package com.ls.socketio.bean;

import lombok.*;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * 酒店栋数
 * @author liShan
 * @date 2019/9/3 11:21
 */
@Getter
@Setter
@ToString
@Entity(name = "build")
public class BuildInfo implements Serializable {

    @Id
    @Column(name = "build_id")
    private int buildId;

    @Column(name = "hotel_id")
    private int hotelId;

    @Column(name = "build_num")
    private int buildNum;

    @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.MERGE)
    @JoinColumn(name = "build_id")
    private List<LayerInfo> layerInfos;

    public BuildInfo() {
    }

    private BuildInfo(Builder builder) {
        this.buildId = builder.buildId;
        this.hotelId = builder.hotelId;
        this.buildNum = builder.buildNum;
        this.layerInfos = builder.layerInfos;
    }

    public static Builder builder() {
        return new Builder();
    }

    public static class Builder{

        private int buildId;
        private int hotelId;
        private int buildNum;
        private List<LayerInfo> layerInfos;

        public Builder buildId(int buildId){
            this.buildId = buildId;
            return this;
        }

        public Builder hotelId(int hotelId){
            this.hotelId = hotelId;
            return this;
        }

        public Builder buildNum(int buildNum){
            this.buildNum = buildNum;
            return this;
        }

        public Builder layerInfos(List<LayerInfo> layerInfos){
            this.layerInfos = layerInfos;
            return this;
        }

        public BuildInfo build() {
            return new BuildInfo(this);
        }

    }

}
